let uu = document.querySelector('.uu')
let xie = document.querySelector('.xie>b:nth-of-type(1)')
let foot = document.querySelector('.footer')
let span = document.querySelector('span')
fetch('http://chst.vip:1234/api/getbrandtitle')
    .then(body => body.json())
    .then(res => {
        let _this = res.result
        console.log(_this)
        let domStr = ''
        _this.forEach(item => {
            domStr += `<li  brandtitleid=${item.brandTitleId}>
        ${item.brandTitle}
        <div>
        <div class="xiang"></div>
        </div>
        </li>`
            uu.innerHTML = domStr
        })
    })
uu.onclick = function (e) {
    if (e.target.localName === 'li') {
        console.log(e.target)
        let _this = e.target
        console.log(_this)
        let titleid = _this.getAttribute('brandtitleid')
        titleid = Number(titleid)
        console.log(titleid)
        fetch("http://chst.vip:1234/api/getbrand?brandtitleid=" + titleid)
            .then(body => body.json())
            .then(res => {
                console.log(res)
                let listArr = res.result
                let listStr = ''
                listArr.forEach(item => {
                    listStr += `<div><a href = "./../html/pinpaixiang.html?name=${item.brandName}&brandtitleid=${item.brandId}"><p brandtitleid="${item.brandId}">${item.brandName}</p></a></div>`
                    $(_this).find('.xiang').html(listStr)
                })
            })
    }
}
xie.onclick = function () {
    location.href = "./../index.html"
}
span.onclick = function () {
    location.href = "./../index.html"
}
foot.onclick = function () {
    location.href = "./../index.html"
}

$('.uu').find('.xiang').slideUp(0, function () {
    $('.xiang').css('display', 'none')
    $('.xiang').prop('flag', false)
})
$('.uu').on('click', 'li', function () {
    console.log(this)
    let flag = $(this).find('.xiang').prop('flag')
    if (flag) {
        $(this).find('.xiang').slideUp(500).prop('flag', false)
        return
    }
    $(this).find('.xiang').slideDown(500).prop('flag', true).parent().parent().siblings().find('.xiang').slideUp(500).prop('flag', false)
})

span.onclick = function () {
    location.href = "./../index.html"
}
foot.onclick = function () {
    location.href = "./../index.html"
}